//
//  MediaShareData.m
//  MediaShareBB
//
//  Created by Artak Gevorgyan on 7/11/13.
//  Copyright (c) 2013 InnoriseEntertainment. All rights reserved.
//

#import "MediaShareData.h"
#import "MediaShareBBUtilityMethods.h"

@implementation MediaShareData

-(id) initWithImage:(UIImage*) image andName:(NSString*) imageFileName {
	self = [super init];
	if (self) {
		_data = [MediaShareBBUtilityMethods dataFromImage:image];
		_fileName = imageFileName;
		_mediaType = IMAGE_MEDIA_TYPE;
	}
	return self;
}

-(id) initWithVideoAtPath:(NSString*) path andName:(NSString*) videoFileName {
	self = [super init];
	if (self) {
		_fileName = videoFileName;
		_path = path;
		_data = [NSData dataWithContentsOfFile:_path];
		_mediaType = VIDEO_MEDIA_TYPE;
	}
	return self;
}

-(id) initPropertiesBasedOnDictionary:(NSString*) path withDictionary:(NSDictionary*) dic {
    self = [super init];
	if (self) {
		_fileName = [dic objectForKey:@"nameKey"];
        _description = [dic objectForKey:@"descriptionKey"];
        _youtubeTags = [dic objectForKey:@"tagsKey"];
        _privacySetings = [dic objectForKey:@"setingsKey"];
		_path = path;
		_data = [NSData dataWithContentsOfFile:_path];
		_mediaType = VIDEO_MEDIA_TYPE;
	}
	return self;
}

-(id) initWithURL:(NSString*) url {
    self = [super init];
	if (self) {
        _fileName = url;
		_mediaType = URL_MEDIA_TYPE;
	}
	return self;
}

-(NSString*) videoFilePath {
	NSString* path = [[NSBundle mainBundle] pathForResource:_fileName
                                                     ofType:@"mp4"];
	return path;
}

@end
